﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Uniforax.Camp.TestData.SmallStake;
using Uniforax.Core.Common;
using Uniforax.Core.Skills;

namespace Uniforax.Camp.TestData.TheTech
{
    // 解锁力量升级。
    public class UnlockPowerUpSkill : BaseSkill
    {
        // 解锁升级，并且对现在的存在的老单位进行主动升级。
        public override void Effect(ActionContext context, SkillContext skillContext)
        {
            var world = context.GameWorld;

            {   // 解锁该权限。
                var unlockPowerUpAction = new UnlockPowerUpAction();
                context.History.Add(unlockPowerUpAction);
                unlockPowerUpAction.Execute(context);
            }

            {   // 进行指定对象的升级。
                var smallStakeQuery = world.QueryDescendants().OfType<SmallStake.SmallStake>();
                foreach (var gameObject in smallStakeQuery)
                {
                    var upgradeAttackAction = new UpgradeSmallStakeAction(gameObject);
                    context.History.Add(upgradeAttackAction);
                    upgradeAttackAction.Execute(context);
                }
            }


            // UnlockPowerUpAction
        }
    }
}
